//
//  LGAdviceRecordDateHeader.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/10/8.
//

#import "LGAdviceRecordDateHeader.h"

@interface LGAdviceRecordDateHeader()
/**   */
@property (nonatomic , strong)UIView *lineView;
/**   */
@property (nonatomic , strong)UILabel *dateLabel;
/**   */
@property (nonatomic , strong)UILabel *nameLabel;
/**   */
@property (nonatomic , strong)UILabel *typeLabel;

@end

@implementation LGAdviceRecordDateHeader

- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubView];
    }
    return self;
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    self.dateLabel.text = LGNSString(dataDic[@"advice_date"]);
    self.nameLabel.text = LGNSString(dataDic[@"doctor_name"]);
    self.typeLabel.text = LGNSString(dataDic[@"source"]);
    self.nameLabel.hidden = [dataDic[@"source_type"] isEqualToString:@"advice"]?NO:YES;
    self.typeLabel.hidden = [dataDic[@"source_type"] isEqualToString:@"advice"]?YES:NO;
}

#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    [self addSubview:self.lineView];
    [self addSubview:self.dateLabel];
    [self addSubview:self.nameLabel];
    [self addSubview:self.typeLabel];
    [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.lineView.mas_right).offset(viewPix(12));
        make.centerY.equalTo(self.lineView);
    }];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.dateLabel.mas_right).offset(viewPix(8));
        make.centerY.equalTo(self.lineView);
    }];
    [self.typeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.dateLabel.mas_right).offset(viewPix(8));
        make.centerY.equalTo(self.lineView);
        make.width.equalTo(@(viewPix(56)));
        make.height.equalTo(@(viewPix(18)));
    }];
}
-(UIView *)lineView{
    if(!_lineView){
        _lineView = [[UIView alloc] initWithFrame:CGRectMake(viewPix(16), viewPix(15), 4, viewPix(14))];
        _lineView.backgroundColor = [UIColor colorWithString:@"#77D4C6"];
        _lineView.cornerRidus = 2;
    }
    return _lineView;
}

-(UILabel *)dateLabel{
    if(!_dateLabel){
        _dateLabel = [UILabel lableWithText:@"" colorString:@"#333333" textFont:LGFontWeight(14, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _dateLabel;
}

-(UILabel *)nameLabel{
    if(!_nameLabel){
        _nameLabel = [UILabel lableWithText:@"" colorString:@"#666666" textFont:LGFontWeight(14, UIFontWeightMedium) textAlignment:NSTextAlignmentLeft lines:1];
    }
    return _nameLabel;
}

-(UILabel *)typeLabel{
    if(!_typeLabel){
        _typeLabel = [UILabel lableWithText:@"" colorString:@"#4C87FD" textFont:LGFontWeight(12, UIFontWeightMedium) textAlignment:NSTextAlignmentCenter lines:1];
        _typeLabel.backgroundColor = [UIColor colorWithString:@"#EAF4FF"];
        _typeLabel.cornerRidus = viewPix(9);
        _typeLabel.hidden = YES;
    }
    return _typeLabel;
}


@end
